package com.ruoyi.web.controller.MES;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.ERP.MaterialDataErp;
import com.ruoyi.system.domain.HUAWEI.EmsBarcodeAttribute;
import com.ruoyi.system.domain.HUAWEI.EmsBarcodeRelation;
import com.ruoyi.system.domain.MES.OrderInfoUpDTO;
import com.ruoyi.system.domain.WMS.RefuelingOrderDTO;
import com.ruoyi.system.service.IEmsBarcodeAttributeService;
import com.ruoyi.system.service.IEmsBarcodeRelationService;
import com.ruoyi.system.service.IEmsBarcodeShipmentService;
import com.ruoyi.system.service.impl.EmsBarcodeAttributeServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description: mes Api
 * @author: zhengxiong.jiang
 * @createDate: 2023/8/15
 * @version: 1.0
 */
@Api(tags = "mes接口api")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/mes" )
public class MesController {

    @Autowired
    private IEmsBarcodeShipmentService shipmentService;
    @Autowired
    private IEmsBarcodeAttributeService emsBarcodeAttributeService;

    @PostMapping("/deleteShipment")
    @ApiOperation(value = "华为回传出库信息删除")
    public AjaxResult deleteShipment(@RequestBody List<String> list) {
        return AjaxResult.success(shipmentService.deleteShipment(list));
    }

    @PostMapping("/sendOrderInfoLine01")
    @ApiOperation(value = "发送工单信息至MES")
    public AjaxResult sendOrderInfoLine01(@RequestBody OrderInfoUpDTO orderInfoUpDTO) {
        return AjaxResult.success(shipmentService.sendOrderInfoLine01(orderInfoUpDTO));
    }

    @PostMapping("/sendOrderInfoLine02")
    @ApiOperation(value = "发送工单信息至MES")
    public AjaxResult sendOrderInfoLine02(@RequestBody OrderInfoUpDTO orderInfoUpDTO) {
        return AjaxResult.success(shipmentService.sendOrderInfoLine02(orderInfoUpDTO));
    }

    @PostMapping("/materielDemandOrders")
    @ApiOperation(value = "产线叫料")
    public AjaxResult materielDemandOrders(@RequestBody List<RefuelingOrderDTO> refuelingOrderDTOs) {
        return AjaxResult.success(shipmentService.materielDemandOrders(refuelingOrderDTOs));
    }

    @PostMapping("/queryAttributeReturn")
    @ApiOperation(value = "根据任务令与21条码查询华为返修结果")
    public AjaxResult queryAttributeReturn(@RequestBody EmsBarcodeAttribute emsBarcodeAttribute) {
        return emsBarcodeAttributeService.queryAttributeReturn(emsBarcodeAttribute);
    }


    @GetMapping("/rabbitmqSendTest/{queue}")
    @ApiOperation(value = "发送消息至队列测试")
    public AjaxResult rabbitmqSendTest(@PathVariable("queue") String queue) {
        return AjaxResult.success(shipmentService.rabbitmqSendTest(queue));
    }

    @PostMapping("/unbindingRelation")
    @ApiOperation(value = "EMS_BARCODE_RELATION数据解绑")
    public AjaxResult unbindingRelation(@RequestBody List<EmsBarcodeRelation> list) {
        return AjaxResult.success(shipmentService.unbindingRelation(list));
    }

    @PostMapping("/queryRelationUnbind")
    @ApiOperation(value = "EMS_BARCODE_RELATION解绑信息查询")
    public AjaxResult queryRelationUnbind(@RequestBody EmsBarcodeRelation emsBarcodeRelation) {
        return AjaxResult.success(shipmentService.queryRelationUnbind(emsBarcodeRelation));
    }

    @PostMapping("/queryRelationBind")
    @ApiOperation(value = "EMS_BARCODE_RELATION绑定信息查询")
    public AjaxResult queryRelationBind(@RequestBody EmsBarcodeRelation emsBarcodeRelation) {
        return AjaxResult.success(shipmentService.queryRelationBind(emsBarcodeRelation));
    }



}
